home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / move.arc / MOVE.DOC < prev   
Encoding:
Text File  |  1985-04-05  |  3.0 KB  |  69 lines

  1.  
  2.    This documentation file describes a batch file called MOVE.BAT.  There is
  3. no accompanying "program" file as it is contained within.
  4.  
  5.    While developing a program, I often found myself moving files from one
  6. directory to another.  Since DOS does not have a "move" command, I was using
  7. the commands "copy" and "del" as follows:
  8.  
  9.       COPY filespec destination
  10.       DEL filespec
  11.  
  12. For example:
  13.  
  14.       COPY myfile \work\prog
  15.       DEL myfile
  16.  
  17.    As you can imagine, this got tiresome after a while.  Batch files to the
  18. rescue!  I wrote a very simple batch file called MOVE.BAT consisting of the
  19. commands
  20.  
  21.       COPY %1 %2
  22.       DEL %1
  23.  
  24. which is just a generalization of the commands above.  The example given above
  25. would be entered as:
  26.  
  27.       MOVE myfile \work\prog
  28.  
  29. which seems like a logical solution to the problem.  There are, however, some
  30. hidden hazards in doing this.
  31.  
  32.    If DOS cannot copy your file for some reason, the "copy" command will fail
  33. and the next command, "del", is executed.  Your file will be deleted and the
  34. (possibly only!) original copy is gone!  Common causes of this would be a
  35. destination file marked read only or a full disk/directory.  In this case I
  36. recommend you have a copy of Peter Norton's UNERASE utility handy.
  37.  
  38.    One might be tempted to solve this problem by using the IF EXIST batch sub-
  39. command of DOS 2.0:
  40.  
  41.       COPY %1 %2
  42.       if exist %2\%1 DEL %1
  43.  
  44. This method first checks to make sure that the destination file exists before
  45. deleting the source file.  Alas, path names are not allowed with "if exist"
  46. (see DOS 2.0 manual, page 6-41) and so this would be useful only for files in
  47. the current directory (the net effect would be the same as "rename").  The
  48. first (and simpler) version of move works with paths for both the source and
  49. destination.
  50.  
  51.    If you specify a nonexistant (misspelled?) directory name as the second
  52. argument to MOVE,  DOS simply creates the destination file in the current
  53. working directory.  If you specify a nonexistant source file, DOS complains,
  54. but no harm is done.
  55.  
  56.    MOVE will probably be most useful if you have a hard disk but is equally
  57. useable for floppies.  The more directories you have, the more useful it will
  58. be.  The global filename templates "*" and "?" work fine with MOVE and enhance
  59. its power.  I keep MOVE.BAT in my \DOS directory with all the other DOS commands
  60. and have that directory on my "path" so I can use it just like any other DOS
  61. command anywhere in my system.
  62.  
  63.    This "program" has been submitted for publication in PC-WORLD's *.* column.
  64.  
  65.                                        Tony Alan Rhea
  66.                                        1030 Ivy Lane
  67.                                        Cary, NC  27511
  68.                                        (919) 467-7143
  69.